package com.bestow.basic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bestow.common.annotation.Log;
import com.bestow.common.core.controller.BaseController;
import com.bestow.common.core.domain.AjaxResult;
import com.bestow.common.enums.BusinessType;
import com.bestow.basic.domain.HlsDocumentCategory;
import com.bestow.basic.service.IHlsDocumentCategoryService;
import com.bestow.common.utils.poi.ExcelUtil;
import com.bestow.common.core.page.TableDataInfo;

/**
 * 租赁单据类别Controller
 * 
 * @author liliu
 * @date 2022-09-02
 */
@RestController
@RequestMapping("/basic/documentCategory")
public class HlsDocumentCategoryController extends BaseController
{
    @Autowired
    private IHlsDocumentCategoryService hlsDocumentCategoryService;

    /**
     * 查询租赁单据类别列表
     */
    @PreAuthorize("@ss.hasPermi('basic:documentCategory:list')")
    @GetMapping("/list")
    public TableDataInfo list(HlsDocumentCategory hlsDocumentCategory)
    {
        startPage();
        List<HlsDocumentCategory> list = hlsDocumentCategoryService.selectHlsDocumentCategoryList(hlsDocumentCategory);
        return getDataTable(list);
    }

    /**
     * 导出租赁单据类别列表
     */
    @PreAuthorize("@ss.hasPermi('basic:documentCategory:export')")
    @Log(title = "租赁单据类别", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HlsDocumentCategory hlsDocumentCategory)
    {
        List<HlsDocumentCategory> list = hlsDocumentCategoryService.selectHlsDocumentCategoryList(hlsDocumentCategory);
        ExcelUtil<HlsDocumentCategory> util = new ExcelUtil<HlsDocumentCategory>(HlsDocumentCategory.class);
        util.exportExcel(response, list, "租赁单据类别数据");
    }

    /**
     * 获取租赁单据类别详细信息
     */
    @PreAuthorize("@ss.hasPermi('basic:documentCategory:query')")
    @GetMapping(value = "/{documentCategory}")
    public AjaxResult getInfo(@PathVariable("documentCategory") String documentCategory)
    {
        return AjaxResult.success(hlsDocumentCategoryService.selectHlsDocumentCategoryByDocumentCategory(documentCategory));
    }

    /**
     * 新增租赁单据类别
     */
    @PreAuthorize("@ss.hasPermi('basic:documentCategory:add')")
    @Log(title = "租赁单据类别", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HlsDocumentCategory hlsDocumentCategory)
    {
        return toAjax(hlsDocumentCategoryService.insertHlsDocumentCategory(hlsDocumentCategory));
    }

    /**
     * 修改租赁单据类别
     */
    @PreAuthorize("@ss.hasPermi('basic:documentCategory:edit')")
    @Log(title = "租赁单据类别", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HlsDocumentCategory hlsDocumentCategory)
    {
        return toAjax(hlsDocumentCategoryService.updateHlsDocumentCategory(hlsDocumentCategory));
    }

    /**
     * 删除租赁单据类别
     */
    @PreAuthorize("@ss.hasPermi('basic:documentCategory:remove')")
    @Log(title = "租赁单据类别", businessType = BusinessType.DELETE)
	@DeleteMapping("/{documentCategorys}")
    public AjaxResult remove(@PathVariable String[] documentCategorys)
    {
        return toAjax(hlsDocumentCategoryService.deleteHlsDocumentCategoryByDocumentCategorys(documentCategorys));
    }
}
